package com.memoir.exception;

import com.memoir.model.enums.ResponseConstantEnums;

/**
 * 条件成立抛出一场
 */
public class ThrowUtils {
    /**
     * 条件成立则抛异常
     *
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    /**
     * 条件成立则抛异常
     *
     * @param condition
     * @param enums 异常的枚举
     */
    public static void throwIf(boolean condition, ResponseConstantEnums enums) {
        throwIf(condition, new BusinessException(enums));
    }
}
